package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Bg;
import vip.xiaonuo.smzq.modular.kcl.service.IBgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


/**
 * 报告
 *
 * @author eomer
 * @since 2024-02-22
 */
@Api(tags = "报告")
@RestController
@RequestMapping("/kcl/bg")
@Validated
public class BgController {

    @Resource
    private IBgService iBgService;

    /**
     * 添加报告
     */
    @ApiOperation("添加报告")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Bg bg) {
        iBgService.save(bg);
        return CommonResult.ok();
    }

    /**
     * 删除报告
     */
    @ApiOperation("删除报告")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iBgService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑报告
     */
    @ApiOperation("编辑报告")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Bg bg) {
        iBgService.updateById(bg);
        return CommonResult.ok();
    }

    /**
     * 报告分页查询
     */
    @ApiOperation("报告分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Bg>> page() {
        return CommonResult.data(iBgService.page(new Bg()));
    }
    /**
     * 报告分页查询
     */
    @ApiOperation("报告分页查询")
    @GetMapping("/getBgList")
    public CommonResult<List<Bg>> getBgList(
            @ApiParam(name = "kqbm", value = "矿区编码", required = true) @RequestParam String kqbm,
            @ApiParam(name = "djflbm", value = "登记分类编码", required = true) @RequestParam Integer djflbm,
            @ApiParam(name = "nd", value = "年度", required = true) @RequestParam Integer nd
    ) {
        return CommonResult.data(iBgService.getBgList(kqbm, djflbm, nd));
    }
}
